package com.sc.controller;

import com.sc.common.pojo.PictureResult;
import com.sc.common.utils.JsonUtils;
import com.sc.service.PictureService;
import org.csource.common.MyException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * Created by sc on 2017/10/11.
 */

@Controller
public class PictureController {

    @Autowired
    private PictureService pictureService;

    @RequestMapping("/pic/upload")
    @ResponseBody
    public String uploadFile(@RequestParam("uploadFile") MultipartFile uploadFile) throws IOException, MyException {
         PictureResult pictureResult = pictureService.uploadPic(uploadFile);
        String json = JsonUtils.objectToJson(pictureResult);
        return json;
    }
}
